import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:sp_util/sp_util.dart';
import 'package:storage/database.dart';
import 'package:storage/pages/splash_page.dart';
import 'package:window_manager_plus/window_manager_plus.dart';

void main(List<String> args) async {
  WidgetsFlutterBinding.ensureInitialized();
  await SpUtil.getInstance();
  await WindowManagerPlus.ensureInitialized(
      args.isEmpty ? 0 : int.tryParse(args[0]) ?? 0);

  // Now you can use the plugin, such as WindowManagerPlus.current
  WindowOptions windowOptions = const WindowOptions(
    size: Size(1400, 800),
    center: true,
    backgroundColor: Colors.transparent,
    skipTaskbar: false,
    titleBarStyle: TitleBarStyle.hidden,
  );
  WindowManagerPlus.current.waitUntilReadyToShow(windowOptions, () async {
    await WindowManagerPlus.current.show();
    await WindowManagerPlus.current.focus();
  });
  await DatabaseHelper().database;
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Storage',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,

      ),
      localizationsDelegates:  const [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: const [
        Locale('zh', 'CN'), // 添加中文支持
      ],
      home: const SplashPage(),
    );
  }
}
